#ifndef __PVMOUTSTREAMHELPERS_H__
#define __PVMOUTSTREAMHELPERS_H__

#include "pvm/pvmapi.h"
#include "lib/pvmsystem.h"

#include "lib/memory/pvmmemory.h"

class PVMHFileOutputStream : public IPvmOutStream, public PVMAllocableObject
{
	PVMHFileOutputStream();
public:
	static IPvmOutStream* CreateW(const pvm_char* fileName, pvm_bool truncateFile);

	virtual ~PVMHFileOutputStream();

	virtual pvm_size Write(void *buf, pvm_size size);
	virtual pvm_bool Seek(pvm_file_size pos, TPvmSeek origin);
	virtual pvm_file_size Tell();
	virtual void Close();
	virtual pvm_file_size Size();
	virtual pvm_bool Seekable();
protected:
	pvm_char* name;
	PVMFileHandle file;
};


class PVMOutCallbacksStream : public IPvmOutStream, public PVMAllocableObject
{
public:
	PVMOutCallbacksStream(IPVMWriteCallbacks* callbacks, void *src);
	virtual ~PVMOutCallbacksStream();

	virtual pvm_size Write(void *buf, pvm_size size);
	virtual pvm_bool Seek(pvm_file_size pos, TPvmSeek origin);
	virtual pvm_file_size Tell();
	virtual void Close();
	virtual pvm_file_size Size();
	virtual pvm_bool Seekable();
protected:
	IPVMWriteCallbacks* callbacks;
	void *src;
};

#endif
